package com.example.esc_im_client.ui.my;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import com.example.esc_im_client.databinding.ActivityMyBinding;


/**
 * @ClassName: DemoFragment
 * @Description:
 * @Author: 墨渍
 * @Date: 2023/8/23 22:55
 **/
public class MyFragment extends Fragment {

    private ActivityMyBinding binding;




    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        Log.d("我，界面初始化","初始化");
        MyViewModel dashboardViewModel =
                new ViewModelProvider(this).get(MyViewModel.class);

        binding = ActivityMyBinding.inflate(inflater, container, false);
        View root = binding.getRoot();

        final TextView textView = binding.myText;
        final TextView textView1 = binding.myText1;

        dashboardViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);
        dashboardViewModel.getText1().observe(getViewLifecycleOwner(), textView1::setText);
        return root;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binding = null;
    }
}
